#include <ratio>
#include <optional>
#include "ProtoVanEmdeBoasTree.h"

bool ProtoVanEmdeBoas<0>::member(size_t x) const
{
	if (x >= u)
		return false;

	return arr[x];
}

auto ProtoVanEmdeBoas<0>::min() const->std::optional<size_t>
{
	if (arr[0])
		return 0;

	if (arr[1])
		return 1;

	return std::nullopt;
}

auto ProtoVanEmdeBoas<0>::successor(size_t x) const->std::optional<size_t>
{
	if (!x && arr[1])
		return 1;

	return std::nullopt;
}

bool ProtoVanEmdeBoas<0>::insert(size_t x)
{
	if (x >= u)
		return false;

	arr[x] = true;
	return true;
}